<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/transferDetail' }">转正管理列表</el-breadcrumb-item>
        <el-breadcrumb-item>
          <i class="el-icon-lx-cascades"></i>
          {{pageTitle}}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div class="table-form-box">
        <h3 class="h3">人事调动详情</h3>

        <table
          border="0"
          width="100%"
          cellpadding="0"
          cellspacing="1"
        >
          <tbody>
            <tr class="tr-title">
              <td colspan="6">基本信息</td>
            </tr>
            <tr>
              <td align="right">单据编号:</td>
              <td>
                {{formData.recordNo}}
              </td>
              <td align="right">
                <span class="color-ff2200">*</span>姓名:
              </td>
              <td>
                {{formData.shuffUserName}}
              </td>

              <td align="right">
                <span class="color-ff2200">*</span>调动类型:
              </td>
              <td>
                {{formData.shuffTypeName}}
              </td>
            </tr>
            <tr>
              <td align="right">目前部门:</td>
              <td>
                {{formData.befDepartName}}
              </td>
              <td align="right">目前岗位:</td>
              <td>
                {{formData.befRole}}
              </td>
              <td align="right">
                <span class="color-ff2200">*</span>调动日期:
              </td>
              <td>
                {{formData.applyTime|formatDate}}
              </td>
            </tr>
            <tr>
              <td align="right">
                <span class="color-ff2200">*</span>调至部门:
              </td>
              <td>
                {{formData.aftDepartName}}
              </td>
              <td align="right">
                <span class="color-ff2200">*</span>调至岗位:
              </td>
              <td>
                {{formData.aftRole}}
              </td>
              <td align="right">
                <span class="color-ff2200">*</span>生效日期:
              </td>
              <td>
                {{formData.validTime|formatDate}}
              </td>
            </tr>
            <tr>
              <td align="right">备注:</td>
              <td colspan="5">
                {{formData.remarks}}
              </td>
            </tr>
          </tbody>
        </table>

        <upload-files
          :files="fileList"
          @fun="dealFiles"
          :isShowDel="false"
          v-if="flag"
        ></upload-files>
      </div>
    </div>

  </div>
</template>

<script>
import appMain from '../../../utils/app_main';
export default {
    name: 'transferDetail',
    data() {
        return {
            pageTitle: '',
            formData: {
                aftDepartId: '', //调动后部门ID
                aftDepartName: '', //调动后部门名称
                aftRole: '', //调动后岗位
                aftRoleId: '', //调动后岗位ID
                applyTime: '', //调动日期
                befDepartId: '', //调动前部门ID
                befDepartName: '', //调动前部门名称
                befRole: '', //调动前岗位
                befRoleId: '', //调动前岗位ID
                recordNo: '', //单据编码
                remarks: '', //备注信息
                shuffTypeId: '', //调动类型Id   字典查询
                shuffTypeName: '', //调动类型名称  字典查询
                shuffTypeValue: '', //调动类型值  字典查询
                shuffUserId: '', //调动人员id
                shuffUserName: '', //调动人员名字
                validTime: '' //生效日期
            },
            flag: false,
            isEdit: false,
            editId: '',
            // 上传文件,选择的文件
            fileList: []
        };
    },
    created() {
        // 如果有id就是跳转过来修改的
        if (this.$route.query.id) {
            this.editId = this.$route.query.id;
            this.isEdit = true;
            this.getData(); // 获取要修改的数据
        } else {
            this.$router.push({
                path: '/transferList' //跳转的路径
            });
        }
    },
    methods: {
        getData() {
            appMain
                .transferFindById({}, this.editId)
                .then(res => {
                    if (res.data.code === 20000) {
                        this.formData = res.data.data;
                        //获取人员档案附件
                        this.uploadFileInfoFindById(this.formData.id);
                    } else {
                        this.$message.error(res.data.message);
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //根据id查询附件
        uploadFileInfoFindById(id) {
            appMain
                .uploadFileInfoFindById({}, id)
                .then(res => {
                    if (res.data.code === 20000) {
                        this.fileList = res.data.data;
                        this.flag = true;
                    } else {
                        this.$message.error(res.data.message);
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        // 上传文件返回
        dealFiles(data) {
            this.fileList = data.backData;
            this.formData.uploadReturns = this.fileList;
        }
    },
    mounted() {
        this.pageTitle = this.$router.currentRoute.meta.title;
    },
    filters: {
        //时间过滤器
        formatDate: function(val) {
            let date = new Date(val);
            return appMain.formatDate(date, 'yyyy-MM-dd hh:mm:ss');
        }
    }
};
</script>

<style scoped>
.container {
    padding-bottom: 50px;
}
.handle-box {
    padding: 5px 50px;
    width: 100%;
    background-color: #fff;
    position: absolute;
    left: 0;
    bottom: 0px;
    border-bottom: 1px solid #ddd;
    border-top: 1px solid #ddd;
    z-index: 1;
}

.table {
    width: 100%;
    font-size: 14px;
}

.table-form-box table {
    background-color: #666;
}
.table-form-box .h3 {
    font-size: 22px;
    text-align: center;
    font-weight: normal;
    padding: 20px 0;
}
.table-form-box table .tr-title td {
    font-size: 14px;
    line-height: 40px;
}
.table-form-box table td,
.table-form-box table th {
    background-color: #fff;
    padding: 4px;
    min-height: 40px;
    font-size: 12px;
}
.color-ff2200 {
    color: #ff2200;
}
</style>
